<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="support.*, java.util.*, myclasses.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Country of residence</title>
</head>
<body>
<% 	
	Student stud = (Student)session.getAttribute("student");
	String citizenship = (String)request.getParameter("citizenship");
	stud.setCitizenship(citizenship);
	
	/* OLD VERSION!!
	String citizenship = request.getParameter("citizenship");
	session.setAttribute("citizenship", citizenship);

	String firstName = (String)session.getAttribute("firstName");
	String middleInitial = (String)session.getAttribute("middleInitial");
	String lastName = (String)session.getAttribute("lastName");
	*/
	%>
<center>
<!-- PERHAPS MAKE A PRINT METHOD FOR THE STUDENT SO WE DONT HAVE TO WRITE THIS CODE EVERY TIME? -->
<%= stud.getFirstName() %> <%= stud.getMiddleInitial() %>. <%= stud.getLastName() %> you chose <%= stud.getCitizenship() %> as your country of citizenship.<br>
Please choose your country of residence:<br>
</center>

<% 	out.println("<center>");
	out.println("<a href=\"http://localhost:8080/GraduateSchoolApp/address.jsp?residence=" + citizenship + "\">" + "Same as country of citizenship" + "</a>");
	out.println("</center>");
	
	String path1 = config.getServletContext().getRealPath("countries.txt");
	support s = new support();
	Vector countries = s.getCountries(path1);

	Integer columncounter = 0;
	out.println("<br>");
	out.println("<table width=\"600\" border=\"2\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\">");
	for(int i=0; i<countries.size(); i++) {
		columncounter += 1;
		if(columncounter == 1)
			out.println("<tr>");
	
		out.println("<td>" + "<a href=\"http://localhost:8080/GraduateSchoolApp/address.jsp?residence=" + countries.get(i) + "\">" + countries.get(i) + "</a>" + "</td>");
	
		if (columncounter >= 3) {
			out.println("</tr>");
			columncounter = 0;
		}
	}

	out.println("</table>");
	out.println("<br>");%>

</body>
</html>